package com.marco.gisdata.listener;

import com.marco.commons.SpringContextUtils;
import com.marco.gisdata.service.impl.BaiduGisServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * GisDataProcessListener.java
 * Create on 2017/3/23
 * Copyright(c) JD Inc 2017. All Rights Reserved.
 * <pre>
 * 功能说明：
 * </pre>
 */
public class GisDataProcessListener implements ServletContextListener {
    private static final Logger logger = LoggerFactory.getLogger(GisDataProcessListener.class);

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        logger.info("---------处理IP接口调用监听器开启中--------------");
        //开启线程调用新浪接口及处理数据
        final BaiduGisServiceImpl baiduGisService = (BaiduGisServiceImpl) SpringContextUtils.getBeanById
                ("baiduGisServiceImpl");
        new Thread(new Runnable() {
            @Override
            public void run() {
                baiduGisService.obtainApiDataByParam();
                baiduGisService.process();
            }
        }).start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
    }
}
